// var i;
// var $uI_GameEquipInfo_UIBindings = require("./UI_GameEquipInfo_UIBindings");
// var $uIView = require("./UIView");
// var $excel = require("./Excel");
// var $hallGlobalVariable = require("./HallGlobalVariable");
// var $bundleConfig = require("./BundleConfig");
// var $excelUtil = require("./ExcelUtil");
// var $commonUtils = require("./CommonUtils");
// var $buffMag = require("./BuffMag");
// var $const_Game = require("./Const_Game");
// var $gameGlobalVariable = require("./GameGlobalVariable");
// var $logic_GetEquip = require("./Logic_GetEquip");
// var m = cc._decorator;
// var v = m.ccclass;
// var b = m.property;
// var w = m.inspector;
// var I = (function (e) {
//     function t() {
//         var t = (null !== e && e.apply(this, arguments)) || this;
//         t.auto_ui = null;
//         return t;
//     }
//     __extends(t, e);
//     t.prototype.onLoad = function () {
//         this.auto_ui.node_light.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
//     };
//     t.prototype._show = function (e) {
//         var t = this;
//         this.shuiGuoId = e.shuiGuoId;
//         this.level = e.level;
//         this.GetAttribute();
//         var o =
//             $logic_GetEquip.default.I.GetMaxLevel(e.shuiGuoId) ==
//             $gameGlobalVariable.GameGlobalVariable.zaZhongMaxLevel;
//         this.auto_ui.node_zaZhongTip.active = o;
//         if (o) {
//             var n = $excel.Excel.shuiguo(e.shuiGuoId);
//             var i = $excel.Excel.shuiguo($logic_GetEquip.default.I.GetZaZhongId(this.shuiGuoId));
//             this.auto_ui.txt_zaJiaoTipLabel.string = "4阶" + n.name + "可与4阶" + i.name + "杂交合成至5阶";
//             var a = "player" + ((0 != n.jinjieShuiGuoId ? n : i).id - 1e3) + "_5";
//             this.auto_ui.node_zaZhongName.children.forEach(function (e) {
//                 e.active = e.name == a;
//             });
//         }
//         this.auto_ui.node_tianFuNode.active = !1;
//         if (4 == e.level) {
//             this.auto_ui.node_zaZhongTip.active = !1;
//             $commonUtils.default.LoadLevel5Effect(
//                 this.shuiGuoId,
//                 this.auto_ui.node_qiFather,
//                 this.auto_ui.node_huoFather,
//                 this._loadRes.bind(this)
//             );
//             this.auto_ui.node_tianFuNode.active = !0;
//             this._loadRes(
//                 $bundleConfig.BundleNames.Common,
//                 "res/tianfuicon/tianfu_" + e.shuiGuoId + "_1",
//                 cc.SpriteFrame
//             ).then(function (e) {
//                 t.auto_ui.sp_ciTiaoIcon.spriteFrame = e;
//             });
//             var r = -1;
//             $excel.Excel.shuiguohecheng_all.forEach(function (t) {
//                 if (t.shuiguoId == e.shuiGuoId && 0 != t.newTianFuBuff) {
//                     r = t.newTianFuBuff;
//                 }
//             });
//             if (-1 != r) {
//                 var c = $excel.Excel.shuiguo(e.shuiGuoId);
//                 var s = $excel.Excel.shuiguobuff(r);
//                 if (s) {
//                     var u = s.value;
//                     var p = s.buffdesc;
//                     var f = [(p = $commonUtils.default.replaceSymbols(p, "\\n", [""]))];
//                     if (-1 != p.indexOf("X")) {
//                         f = p.split("X");
//                     }
//                     var g = "";
//                     for (var m = 0; m < f.length; m++) {
//                         var v = f[m];
//                         if (-1 != v.indexOf("#")) {
//                             var b = '<color=#ffff00 click="ShowZaZhongInfo">' + c.newName + "</c>";
//                             b = "<u>" + b + "</u>";
//                             v = $commonUtils.default.replaceSymbols(v, "#", [b]);
//                         }
//                         g += "<color=#ffffff>" + v + "</c>";
//                         if (m < f.length - 1 && u) {
//                             g += "<color=#71ff00>" + u[m] + "</c>";
//                         }
//                     }
//                     g = "<outline color=#000000 width=3>" + (g = "<b>" + g + "</b>") + "</outline>";
//                     this.auto_ui.rtxt_ciTiaoInfo.string = g;
//                 }
//             }
//         }
//     };
//     t.prototype._clickListener = function (e) {
//         switch (e) {
//             case this.auto_ui.btn_closeBtn:
//                 this._close();
//         }
//     };
//     t.prototype.GetAttribute = function () {
//         var e = this;
//         var t = $excel.Excel.shuiguo(this.shuiGuoId);
//         this._loadRes(
//             $bundleConfig.BundleNames.Common,
//             "res/player/player" + (this.shuiGuoId - 1e3) + "_" + (this.level + 1),
//             cc.SpriteFrame
//         ).then(function (t) {
//             e.auto_ui.sp_iconSprite.spriteFrame = t;
//         });
//         this.auto_ui.sp_tianFuIcon.spriteFrame = null;
//         if (this.shuiGuoId != $const_Game.FruitId.杨桃忍者) {
//             this._loadRes(
//                 $bundleConfig.BundleNames.Common,
//                 "res/tianfuicon/tianfu_" + this.shuiGuoId,
//                 cc.SpriteFrame
//             ).then(function (t) {
//                 e.auto_ui.sp_tianFuIcon.spriteFrame = t;
//                 $commonUtils.default.LimitSpriteMaxSize(e.auto_ui.sp_tianFuIcon, 80);
//             });
//         }
//         var o = $hallGlobalVariable.default.GetShuiGuoCurrLevelData(this.shuiGuoId);
//         if (this.level == $gameGlobalVariable.GameGlobalVariable.normalMaxLevel) {
//             this.auto_ui.txt_titleLabel.string = t.newName + "(LV." + (this.level + 1) + ")";
//         } else {
//             this.auto_ui.txt_titleLabel.string = t.name + "(LV." + (this.level + 1) + ")";
//         }
//         this.auto_ui.txt_tianFuLabel.string = t.shuiguomiaoshu;
//         var n = ["最前", "随机", "轮流", "精英", "-", "随机", "最前", "-", "-"];
//         var i = this.GetEquipAtk(t, this.level, o[0]);
//         this.GetEquipAtk(t, this.level + 1, o[0]);
//         this.auto_ui.node_attributeFather.children.forEach(function (o, a) {
//             var r = o.getChildByName("value").getChildByName("valueLabel").getComponent(cc.Label);
//             o.getChildByName("value").getChildByName("addLabel").getComponent(cc.Label).string = "";
//             r.string = "-";
//             switch (a) {
//                 case 0:
//                     if (0 != t.attack && e.shuiGuoId != $const_Game.FruitId.辣妹子) {
//                         Math.floor(i.sgattack) < i.sgattack || (i.sgattack < 1 && i.sgattack > 0)
//                             ? (r.string = i.sgattack.toFixed(2))
//                             : (r.string = "" + i.sgattack);
//                     }
//                     break;
//                 case 1:
//                     if (0 != t.attackspeed) {
//                         Math.floor(i.sgattackspeed) < i.sgattackspeed || (i.sgattackspeed < 1 && i.sgattackspeed > 0)
//                             ? (r.string = i.sgattackspeed.toFixed(2))
//                             : (r.string = "" + i.sgattackspeed);
//                     }
//                     break;
//                 case 2:
//                     r.string = n[t.attackstate - 1];
//                     break;
//                 case 3:
//                     var c = !1;
//                     if (t.littleDesc && t.littleDesc.length > 0) {
//                         c = !0;
//                     }
//                     o.getChildByName("nameLabel").getComponent(cc.Label).string = c ? t.littleDesc : "-";
//                     if (c) {
//                         var s = $buffMag.BuffMgr.getShuiGuoBuff(t.id, e.level);
//                         var u = "";
//                         switch (e.shuiGuoId) {
//                             case $const_Game.FruitId.爆头瓜:
//                             case $const_Game.FruitId.榴莲王:
//                             case $const_Game.FruitId.香蕉射手:
//                             case $const_Game.FruitId.黄瓜大棒:
//                             case $const_Game.FruitId.辣妹子:
//                             case $const_Game.FruitId.冻斯梨:
//                             case $const_Game.FruitId.毒蘑菇:
//                             case $const_Game.FruitId.天山雪莲:
//                             case $const_Game.FruitId.元婴果:
//                                 u = "%";
//                         }
//                         r.string = $excel.Excel.shuiguobuff(t.talent).probability + u;
//                         if (e.shuiGuoId == $const_Game.FruitId.榴莲王) {
//                             r.string = $excel.Excel.shuiguobuff(t.talent).probability + u;
//                         } else {
//                             e.shuiGuoId == $const_Game.FruitId.香蕉射手
//                                 ? (r.string = "" + s.otherValue + u)
//                                 : (r.string = "" + s.nowvalue + u);
//                         }
//                     }
//             }
//         });
//     };
//     t.prototype.GetEquipAtk = function (e, t, o) {
//         var n = o.atk;
//         var i = o.atkSpeed;
//         var a = $excelUtil.ExcelUtil.getSameData($excel.Excel.shuiguohecheng_all, "shuiguoId", e.id);
//         if (t >= a.length) {
//             t = a.length - 1;
//         }
//         var r = a[t];
//         return {
//             sgattack: (n += (n * r.addattack) / 100),
//             sgattackspeed: (i /= 1 + r.addattackspeed / 100)
//         };
//     };
//     __decorate([b($uI_GameEquipInfo_UIBindings.default)], t.prototype, "auto_ui", void 0);
//     return __decorate([v], t);
// })($uIView.default);
// exports.default = I;


// import UI_GameEquipInfo_UIBindings from "./UI_GameEquipInfo_UIBindings";
// import UIView from "./UIView";
// import { Excel } from "./Excel";
// import HallGlobalVariable from "./HallGlobalVariable";
// import { BundleNames } from "./BundleConfig";
// import { ExcelUtil } from "./ExcelUtil";
// import CommonUtils from "./CommonUtils";
// import { BuffMgr } from "./BuffMag";
// import { GameGlobalVariable } from "./GameGlobalVariable";
// import Logic_GetEquip from "./Logic_GetEquip";
// import { FruitId } from "./Const_Game";

// const { ccclass, property } = cc._decorator;

// /**
//  * 建议类名: EquipInfoUI
//  * 
//  * 装备信息UI类负责显示水果的装备信息，如等级、属性、技能等
//  */
// @ccclass
// class UI_GameEquipInfo extends UIView {

//     /** 自动生成的UI绑定 */
//     @property(UI_GameEquipInfo_UIBindings)
//     auto_ui: UI_GameEquipInfo_UIBindings = null;

//     /** 水果ID */
//     private shuiGuoId: number;

//     /** 水果等级 */
//     private level: number;

//     /**
//      * 生命周期函数，初始化加载
//      */
//     onLoad() {
//         // 添加旋转的动画效果
//         this.auto_ui.node_light.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
//     }

//     /**
//      * 建议方法名: displayEquipInfo
//      * 
//      * 显示装备信息
//      * 
//      * @param e 装备信息参数
//      */
//     _show(e: { shuiGuoId: number, level: number }) {
//         this.shuiGuoId = e.shuiGuoId;
//         this.level = e.level;

//         // 更新属性显示
//         this.GetAttribute();

//         const isMaxLevel = Logic_GetEquip.I.GetMaxLevel(e.shuiGuoId) === GameGlobalVariable.zaZhongMaxLevel;
//         this.auto_ui.node_zaZhongTip.active = isMaxLevel;

//         if (isMaxLevel) {
//             const currentFruit = Excel.shuiguo(e.shuiGuoId);
//             const zaZhongFruit = Excel.shuiguo(Logic_GetEquip.I.GetZaZhongId(this.shuiGuoId));
//             this.auto_ui.txt_zaJiaoTipLabel.string = `4阶${currentFruit.name}可与4阶${zaZhongFruit.name}杂交合成至5阶`;
//             const playerName = `player${(0 != currentFruit.jinjieShuiGuoId ? currentFruit : zaZhongFruit).id - 1000}_5`;
//             this.auto_ui.node_zaZhongName.children.forEach((child) => {
//                 child.active = child.name === playerName;
//             });
//         }

//         this.auto_ui.node_tianFuNode.active = false;

//         if (4 === e.level) {
//             this.auto_ui.node_zaZhongTip.active = false;

//             // 加载5阶效果
//             CommonUtils.LoadLevel5Effect(
//                 this.shuiGuoId,
//                 this.auto_ui.node_qiFather,
//                 this.auto_ui.node_huoFather,
//                 this._loadRes.bind(this)
//             );

//             this.auto_ui.node_tianFuNode.active = true;

//             // 加载天赋图标资源
//             this._loadRes(
//                 BundleNames.Common,
//                 `res/tianfuicon/tianfu_${e.shuiGuoId}_1`,
//                 cc.SpriteFrame
//             ).then((spriteFrame: cc.SpriteFrame) => {
//                 this.auto_ui.sp_ciTiaoIcon.spriteFrame = spriteFrame;
//             });

//             let newTianFuBuff = -1;
//             Excel.shuiguohecheng_all.forEach((item) => {
//                 if (item.shuiguoId === e.shuiGuoId && 0 !== item.newTianFuBuff) {
//                     newTianFuBuff = item.newTianFuBuff;
//                 }
//             });

//             if (newTianFuBuff !== -1) {
//                 const currentFruit = Excel.shuiguo(e.shuiGuoId);
//                 const buff = Excel.shuiguobuff(newTianFuBuff);
//                 if (buff) {
//                     const buffValue = buff.value;
//                     let buffDesc = buff.buffdesc;
//                     let descParts = [(buffDesc = CommonUtils.replaceSymbols(buffDesc, "\\n", [""]))];

//                     if (buffDesc.includes("X")) {
//                         descParts = buffDesc.split("X");
//                     }

//                     let formattedDesc = "";
//                     descParts.forEach((descPart, index) => {
//                         if (descPart.includes("#")) {
//                             let formattedName = `<color=#ffff00 click="ShowZaZhongInfo">${currentFruit.newName}</c>`;
//                             formattedName = `<u>${formattedName}</u>`;
//                             descPart = CommonUtils.replaceSymbols(descPart, "#", [formattedName]);
//                         }

//                         formattedDesc += `<color=#ffffff>${descPart}</c>`;
//                         if (index < descParts.length - 1 && buffValue) {
//                             formattedDesc += `<color=#71ff00>${buffValue[index]}</c>`;
//                         }
//                     });

//                     formattedDesc = `<outline color=#000000 width=3><b>${formattedDesc}</b></outline>`;
//                     this.auto_ui.rtxt_ciTiaoInfo.string = formattedDesc;
//                 }
//             }
//         }
//     }

//     /**
//      * 建议方法名: clickHandler
//      * 
//      * 点击事件处理
//      * 
//      * @param e 点击事件
//      */
//     _clickListener(e: cc.Button) {
//         switch (e) {
//             case this.auto_ui.btn_closeBtn:
//                 this._close();
//         }
//     }

//     /**
//      * 建议方法名: updateAttributes
//      * 
//      * 更新属性显示
//      */
//     GetAttribute() {
//         const currentFruit = Excel.shuiguo(this.shuiGuoId);

//         // 加载水果图标资源
//         this._loadRes(
//             BundleNames.Common,
//             `res/player/player${this.shuiGuoId - 1000}_${this.level + 1}`,
//             cc.SpriteFrame
//         ).then((spriteFrame: cc.SpriteFrame) => {
//             this.auto_ui.sp_iconSprite.spriteFrame = spriteFrame;
//         });

//         this.auto_ui.sp_tianFuIcon.spriteFrame = null;

//         if (this.shuiGuoId !== FruitId.杨桃忍者) {
//             this._loadRes(
//                 BundleNames.Common,
//                 `res/tianfuicon/tianfu_${this.shuiGuoId}`,
//                 cc.SpriteFrame
//             ).then((spriteFrame: cc.SpriteFrame) => {
//                 this.auto_ui.sp_tianFuIcon.spriteFrame = spriteFrame;
//                 CommonUtils.LimitSpriteMaxSize(this.auto_ui.sp_tianFuIcon, 80);
//             });
//         }

//         const currLevelData = HallGlobalVariable.GetShuiGuoCurrLevelData(this.shuiGuoId);

//         if (this.level === GameGlobalVariable.normalMaxLevel) {
//             this.auto_ui.txt_titleLabel.string = `${currentFruit.newName}(LV.${this.level + 1})`;
//         } else {
//             this.auto_ui.txt_titleLabel.string = `${currentFruit.name}(LV.${this.level + 1})`;
//         }

//         this.auto_ui.txt_tianFuLabel.string = currentFruit.shuiguomiaoshu;

//         const attackStates = ["最前", "随机", "轮流", "精英", "-", "随机", "最前", "-", "-"];

//         const equipAtk = this.GetEquipAtk(currentFruit, this.level, currLevelData[0]);

//         this.GetEquipAtk(currentFruit, this.level + 1, currLevelData[0]);

//         this.auto_ui.node_attributeFather.children.forEach((child, index) => {
//             const valueLabel = child.getChildByName("value").getChildByName("valueLabel").getComponent(cc.Label);
//             child.getChildByName("value").getChildByName("addLabel").getComponent(cc.Label).string = "";

//             valueLabel.string = "-";

//             switch (index) {
//                 case 0:
//                     if (0 !== currentFruit.attack && this.shuiGuoId !== FruitId.辣妹子) {
//                         valueLabel.string = equipAtk.sgattack < 1 && equipAtk.sgattack > 0 ?
//                             equipAtk.sgattack.toFixed(2) :
//                             `${equipAtk.sgattack}`;
//                     }
//                     break;
//                 case 1:
//                     if (0 !== currentFruit.attackspeed) {
//                         valueLabel.string = equipAtk.sgattackspeed < 1 && equipAtk.sgattackspeed > 0 ?
//                             equipAtk.sgattackspeed.toFixed(2) :
//                             `${equipAtk.sgattackspeed}`;
//                     }
//                     break;
//                 case 2:
//                     valueLabel.string = attackStates[currentFruit.attackstate - 1];
//                     break;
//                 case 3:
//                     let hasLittleDesc = false;
//                     if (currentFruit.littleDesc && currentFruit.littleDesc.length > 0) {
//                         hasLittleDesc = true;
//                     }

//                     child.getChildByName("nameLabel").getComponent(cc.Label).string = hasLittleDesc ? currentFruit.littleDesc : "-";

//                     if (hasLittleDesc) {
//                         const buff = BuffMgr.getShuiGuoBuff(currentFruit.id, this.level);
//                         let unit = "";

//                         switch (this.shuiGuoId) {
//                             case FruitId.爆头瓜:
//                             case FruitId.榴莲王:
//                             case FruitId.香蕉射手:
//                             case FruitId.黄瓜大棒:
//                             case FruitId.辣妹子:
//                             case FruitId.冻斯梨:
//                             case FruitId.毒蘑菇:
//                             case FruitId.天山雪莲:
//                             case FruitId.元婴果:
//                                 unit = "%";
//                                 break;
//                         }

//                         valueLabel.string = Excel.shuiguobuff(currentFruit.talent).probability + unit;

//                         if (this.shuiGuoId === FruitId.榴莲王) {
//                             valueLabel.string = Excel.shuiguobuff(currentFruit.talent).probability + unit;
//                         } else {
//                             valueLabel.string = this.shuiGuoId === FruitId.香蕉射手 ?
//                                 `${buff.otherValue}${unit}` :
//                                 `${buff.nowvalue}${unit}`;
//                         }
//                     }
//                     break;
//             }
//         });
//     }

//     /**
//      * 建议方法名: calculateEquipAtk
//      * 
//      * 计算装备攻击力和攻击速度
//      * 
//      * @param e 当前水果信息
//      * @param t 当前等级
//      * @param o 当前数据
//      * @returns 计算后的攻击力和攻击速度
//      */
//     GetEquipAtk(e: any, t: number, o: any) {
//         let n = o.atk;
//         let i = o.atkSpeed;
//         const mergedData = ExcelUtil.getSameData(Excel.shuiguohecheng_all, "shuiguoId", e.id);

//         if (t >= mergedData.length) {
//             t = mergedData.length - 1;
//         }

//         const levelData = mergedData[t];

//         return {
//             sgattack: n + (n * levelData.addattack) / 100,
//             sgattackspeed: i / (1 + levelData.addattackspeed / 100)
//         };
//     }
// }

// export default UI_GameEquipInfo;

import UIGameEquipInfoUIBindings from "./UI_GameEquipInfo_UIBindings";
import UIViewBase from "./UIView";
import { Excel } from "./Excel";
import FruitDataManager from "./HallGlobalVariable";
import { BundleNames } from "./BundleConfig";
import { ExcelUtil } from "./ExcelUtil";
import CommonUtils from "./CommonUtils";
import { BuffMgr } from "./BuffMag";
import { GameGlobalVariable } from "./GameGlobalVariable";
import LogicGetEquip from "./Logic_GetEquip";
import { FruitId } from "./Const_Game";

const { ccclass, property } = cc._decorator;

/**
 * 建议类名: EquipInfoUI
 * 
 * 装备信息UI类负责显示水果的装备信息，如等级、属性、技能等
 */
@ccclass
class ViewGameEquipInfo extends UIViewBase {

    /** 自动生成的UI绑定 */
    @property(UIGameEquipInfoUIBindings)
    auto_ui: UIGameEquipInfoUIBindings = null;

    /** 水果ID */
    private fruitId: number;

    /** 水果等级 */
    private fruitLevel: number;

    /**
     * 生命周期函数，初始化加载
     */
    onLoad() {
        // 添加旋转的动画效果
        this.auto_ui.node_light.runAction(cc.repeatForever(cc.rotateBy(5, 360)));
    }

    /**
     * 建议方法名: displayEquipInfo
     * 
     * 显示装备信息
     * 
     * @param equipInfo 装备信息参数
     */
    _show(equipInfo: { shuiGuoId: number, level: number }) {
        this.fruitId = equipInfo.shuiGuoId;
        this.fruitLevel = equipInfo.level;

        // 更新属性显示
        this.updateAttributes();

        const isMaxLevel = LogicGetEquip.getInstance.getMaxLevel(equipInfo.shuiGuoId) === GameGlobalVariable.zaZhongMaxLevel;
        this.auto_ui.node_zaZhongTip.active = isMaxLevel;

        if (isMaxLevel) {
            const currentFruit = Excel.shuiguo(equipInfo.shuiGuoId);
            const zaZhongFruit = Excel.shuiguo(LogicGetEquip.getInstance.getZaZhongId(this.fruitId));
            this.auto_ui.txt_zaJiaoTipLabel.string = `4阶${currentFruit.name}可与4阶${zaZhongFruit.name}杂交合成至5阶`;
            const playerName = `player${(0 != currentFruit.jinjieShuiGuoId ? currentFruit : zaZhongFruit).id - 1000}_5`;
            this.auto_ui.node_zaZhongName.children.forEach((childNode) => {
                childNode.active = childNode.name === playerName;
            });
        }

        this.auto_ui.node_tianFuNode.active = false;

        if (4 === equipInfo.level) {
            this.auto_ui.node_zaZhongTip.active = false;

            // 加载5阶效果
            CommonUtils.loadLevel5Effect(
                this.fruitId,
                this.auto_ui.node_qiFather,
                this.auto_ui.node_huoFather,
                this._loadRes.bind(this)
            );

            this.auto_ui.node_tianFuNode.active = true;

            // 加载天赋图标资源
            this._loadRes(
                BundleNames.Common,
                `res/tianfuicon/tianfu_${equipInfo.shuiGuoId}_1`,
                cc.SpriteFrame
            ).then((spriteFrame: cc.SpriteFrame) => {
                this.auto_ui.sp_ciTiaoIcon.spriteFrame = spriteFrame;
            });

            let newTianFuBuff = -1;
            Excel.shuiguohecheng_all.forEach((item) => {
                if (item.shuiguoId === equipInfo.shuiGuoId && 0 !== item.newTianFuBuff) {
                    newTianFuBuff = item.newTianFuBuff;
                }
            });

            if (newTianFuBuff !== -1) {
                const currentFruit = Excel.shuiguo(equipInfo.shuiGuoId);
                const buffInfo = Excel.shuiguobuff(newTianFuBuff);
                if (buffInfo) {
                    const buffValue = buffInfo.value;
                    let buffDesc = buffInfo.buffdesc;
                    let descParts = [(buffDesc = CommonUtils.replaceStringSymbols(buffDesc, "\\n", [""]))];

                    if (buffDesc.includes("X")) {
                        descParts = buffDesc.split("X");
                    }

                    let formattedDesc = "";
                    descParts.forEach((descPart, index) => {
                        if (descPart.includes("#")) {
                            let formattedName = `<color=#ffff00 click="ShowZaZhongInfo">${currentFruit.newName}</c>`;
                            formattedName = `<u>${formattedName}</u>`;
                            descPart = CommonUtils.replaceStringSymbols(descPart, "#", [formattedName]);
                        }

                        formattedDesc += `<color=#ffffff>${descPart}</c>`;
                        if (index < descParts.length - 1 && buffValue) {
                            formattedDesc += `<color=#71ff00>${buffValue[index]}</c>`;
                        }
                    });

                    formattedDesc = `<outline color=#000000 width=3><b>${formattedDesc}</b></outline>`;
                    this.auto_ui.rtxt_ciTiaoInfo.string = formattedDesc;
                }
            }
        }
    }

    /**
     * 建议方法名: clickHandler
     * 
     * 点击事件处理
     * 
     * @param button 点击事件
     */
    _clickListener(button: cc.Button) {
        switch (button) {
            case this.auto_ui.btn_closeBtn:
                this._close();
        }
    }

    /**
     * 建议方法名: updateAttributes
     * 
     * 更新属性显示
     */
    updateAttributes() {
        const currentFruit = Excel.shuiguo(this.fruitId);

        // 加载水果图标资源
        this._loadRes(
            BundleNames.Common,
            `res/player/player${this.fruitId - 1000}_${this.fruitLevel + 1}`,
            cc.SpriteFrame
        ).then((spriteFrame: cc.SpriteFrame) => {
            this.auto_ui.sp_iconSprite.spriteFrame = spriteFrame;
        });

        this.auto_ui.sp_tianFuIcon.spriteFrame = null;

        if (this.fruitId !== FruitId.杨桃忍者) {
            this._loadRes(
                BundleNames.Common,
                `res/tianfuicon/tianfu_${this.fruitId}`,
                cc.SpriteFrame
            ).then((spriteFrame: cc.SpriteFrame) => {
                this.auto_ui.sp_tianFuIcon.spriteFrame = spriteFrame;
                CommonUtils.limitSpriteSize(this.auto_ui.sp_tianFuIcon, 80);
            });
        }

        const currLevelData = FruitDataManager.getShuiGuoCurrLevelData(this.fruitId);

        if (this.fruitLevel === GameGlobalVariable.normalMaxLevel) {
            this.auto_ui.txt_titleLabel.string = `${currentFruit.newName}(LV.${this.fruitLevel + 1})`;
        } else {
            this.auto_ui.txt_titleLabel.string = `${currentFruit.name}(LV.${this.fruitLevel + 1})`;
        }

        this.auto_ui.txt_tianFuLabel.string = currentFruit.shuiguomiaoshu;

        const attackStates = ["最前", "随机", "轮流", "精英", "-", "随机", "最前", "-", "-"];

        const equipAtk = this.calculateEquipAtk(currentFruit, this.fruitLevel, currLevelData[0]);

        this.calculateEquipAtk(currentFruit, this.fruitLevel + 1, currLevelData[0]);

        this.auto_ui.node_attributeFather.children.forEach((childNode, index) => {
            const valueLabel = childNode.getChildByName("value").getChildByName("valueLabel").getComponent(cc.Label);
            childNode.getChildByName("value").getChildByName("addLabel").getComponent(cc.Label).string = "";

            valueLabel.string = "-";

            switch (index) {
                case 0:
                    if (0 !== currentFruit.attack && this.fruitId !== FruitId.辣妹子) {
                        valueLabel.string = equipAtk.sgattack < 1 && equipAtk.sgattack > 0 ?
                            equipAtk.sgattack.toFixed(2) :
                            `${equipAtk.sgattack}`;
                    }
                    break;
                case 1:
                    if (0 !== currentFruit.attackspeed) {
                        valueLabel.string = equipAtk.sgattackspeed < 1 && equipAtk.sgattackspeed > 0 ?
                            equipAtk.sgattackspeed.toFixed(2) :
                            `${equipAtk.sgattackspeed}`;
                    }
                    break;
                case 2:
                    valueLabel.string = attackStates[currentFruit.attackstate - 1];
                    break;
                case 3:
                    let hasLittleDesc = false;
                    if (currentFruit.littleDesc && currentFruit.littleDesc.length > 0) {
                        hasLittleDesc = true;
                    }

                    childNode.getChildByName("nameLabel").getComponent(cc.Label).string = hasLittleDesc ? currentFruit.littleDesc : "-";

                    if (hasLittleDesc) {
                        const buff = BuffMgr.getFruitBuff(currentFruit.id, this.fruitLevel);
                        let unit = "";

                        switch (this.fruitId) {
                            case FruitId.爆头瓜:
                            case FruitId.榴莲王:
                            case FruitId.香蕉射手:
                            case FruitId.黄瓜大棒:
                            case FruitId.辣妹子:
                            case FruitId.冻斯梨:
                            case FruitId.毒蘑菇:
                            case FruitId.天山雪莲:
                            case FruitId.元婴果:
                                unit = "%";
                                break;
                        }

                        valueLabel.string = Excel.shuiguobuff(currentFruit.talent).probability + unit;

                        if (this.fruitId === FruitId.榴莲王) {
                            valueLabel.string = Excel.shuiguobuff(currentFruit.talent).probability + unit;
                        } else {
                            valueLabel.string = this.fruitId === FruitId.香蕉射手 ?
                                `${buff.otherValue}${unit}` :
                                `${buff.nowvalue}${unit}`;
                        }
                    }
                    break;
            }
        });
    }

    /**
     * 建议方法名: calculateEquipAtk
     * 
     * 计算装备攻击力和攻击速度
     * 
     * @param fruit 当前水果信息
     * @param level 当前等级
     * @param data 当前数据
     * @returns 计算后的攻击力和攻击速度
     */
    calculateEquipAtk(fruit: any, level: number, data: any) {
        let attack = data.atk;
        let attackSpeed = data.atkSpeed;
        const mergedData = ExcelUtil.getMatchingData(Excel.shuiguohecheng_all, "shuiguoId", fruit.id);

        if (level >= mergedData.length) {
            level = mergedData.length - 1;
        }

        const levelData = mergedData[level];

        return {
            sgattack: attack + (attack * levelData.addattack) / 100,
            sgattackspeed: attackSpeed / (1 + levelData.addattackspeed / 100)
        };
    }
}

export default ViewGameEquipInfo;